using System;
using System.Collections.Generic;
using System.Text;
using NetROS.Tiers.Data;
using NetROS.Tiers.Entities;
using NetRosApp.Infrastructure.Interface.Services;

namespace NetRosApp.Infrastructure.Library.Services
{
    class ParametriAplikacijeService : IParametriAplikacijeService
    {
        private readonly Dictionary<string, string> _actions = new Dictionary<string, string>();
        private DateTime _stamped = new DateTime(1900,1,1);

        public Dictionary<string, string> Actions
        {
            get
            {

                if (_stamped.Year == 1900 || Math.Abs ((DateTime.Now - _stamped).Days*24+(DateTime.Now - _stamped).Hours) > 1)
                {
                    _actions.Clear();
                    _stamped = DateTime.Now;
                    VList<VwParametriKorisnika> _list = DataRepository.VwParametriKorisnikaProvider.GetAll();
                    foreach (VwParametriKorisnika _korisnika in _list)
                    {
                        if (!_actions.ContainsKey(_korisnika.Param))
                        _actions.Add(_korisnika.Param, _korisnika.Vrijednost); 
                    }
                }

                return _actions;
            }
        }

    }
}
